package com.taotao.item.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.taotao.item.pojo.Item;
import com.taotao.pojo.TbItem;
import com.taotao.pojo.TbItemDesc;
import com.taotao.service.ItemService;

/**
 * 商品详情的静态化页面
 * @author created by wq
 * @date   Sep 4, 2017---11:44:28 PM
 * @return
 * @throws Exception<br/>
 *==========History========== <br/>
 * taotao-item-web Sep 4, 2017
 */
@Controller
public class ItemController {

	@Autowired
	private ItemService itemService;
	
	@RequestMapping("/item/{itemId}")
//	@ResponseBody
	public String showItemInfo(@PathVariable Long itemId,Model model){
		//调用业务层服务
		TbItem tbItem = itemService.getItemByItemId(itemId);
		//创建Item
		Item item = new Item(tbItem);
		
		TbItemDesc tbItemDesc = itemService.geTbItemDescByItemId(itemId);
		//将model传递到页面
		model.addAttribute("item", item);
		model.addAttribute("itemDesc", tbItemDesc);
		return "item";
	}
}
